﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Reflection;

namespace demoReflection
{
    class Program
    {
        static void Main(string[] args)
        {


            var ass =  Assembly.Load("demoReflection");

            foreach (var item in ass.GetTypes())
            {
                Console.WriteLine(item.Name);
                
                
            }

            var cl = new Client() { Nombre = "Juan", Dni ="12212121" , Edad=56 };
            AuditMethor(cl);
            Console.WriteLine(cl.Nombre);

            //SPRING , UNITY  DI IOC
            var type = Type.GetType(ConfigurationManager.AppSettings["provider"]);
            IOrderProvider iprovider = Activator.CreateInstance(type) as  IOrderProvider;
            iprovider.MakeOrder(5);
            iprovider.MakeOrder(10);
            iprovider.MakeOrder(15);
            
            dynamic s = type;
            s.Demo();  





            Console.ReadLine(); 

        }

        public static void AuditMethor(object target)
        {
            var type = target.GetType();
            var att = Attribute.GetCustomAttribute(type, typeof(AuditAttribute)) as AuditAttribute;
            if (att != null)
            {
                switch (att.type)
                {
                    case AuditEnum.Low:
                        break;
                    case AuditEnum.Hight:
                        var props = type.GetProperties();
                        foreach (var item in props)
                        {
                            var value = item.GetValue(target, null);
                            Console.WriteLine("{0} => {1}", item.Name, value);                              
                        }
                        break;
                    default:
                        break;
                }
            }


        }


    }




}
